<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>包受理渠道设置</title>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/packagemgr.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/themes/icon.css">
	</head>
	<style>
			.p_c_action_type {
				background-color:#EDF2F5;
				font-family:'新宋体';
				font-size:12px;
				line-height:20px;
				font-weight:noml;
				overflow:hidden;
				padding-top:5px;
			}
	</style>
	<body>
		<div id="publishEditBody" class="p_c_action_type">
			<div style="margin-left:1px;">
				<div id="channelQuery"></div>

			</div>
			<div style="text-align:right; margin-right:10px;">
				<input type="button" value="确定" onclick="javascript:channelConfirm();"/>
				<input type="button" value="取消" onclick="javascript:channelCancel();"/>
			</div>
		</div>
		<script type="text/javascript">
			$(function(){
				$("#channelQuery").datagrid({
					toolbar:[{
           				 text: '渠道名称:<input type="text" id="channelNameSelect"/>'
        			},
        			{
        				iconCls: 'icon-search',
        				handler: function(){
               				querychannel();
            			}
        			}],
        			fitColumns: true,
					nowrap:false,
					showFooter:true,
					striped:true,
					singleSelect:true,
					height:200,
					width:585,
					columns:[[
						{field:'channelId',title:'ID',width:150,align:'left'},
						{field:'name',title:'名称',width:200,align:'left'},
						{field:'areaName',title:'地区',width:100,align:'left'},
						{field:'startDt',title:'开始时间',width:100,align:'left'},
						{field:'endDt',title:'结束时间',width:100,align:'left'}
					]],
					onSelect:function(index, row){
						var flag = false; //标识选中的地区在不在选择列表中
						//首选验证是否已经存在于选择列表中


					},
					pagination:true
				});
				var p = $('#channelQuery').datagrid('getPager');
				$(p).pagination({
					pageSize: 10,//每页显示的记录条数，默认为10
					pageList: [10,15],//可以设置每页记录条数的列表
				 	beforePageText: '第',//页数文本框前显示的汉字
				   	afterPageText: '页    共 {pages} 页',
				   	displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
				});
			});

			function querychannel(){
				var name = $("#channelNameSelect").val();
				var params = {};
				params.name = encodeURIComponent(name);
				params.publishAreaId = g_areaId;
				$('#channelQuery').datagrid({url:'../json/getChannelByName.action',
					queryParams:params});

				var p = $('#channelQuery').datagrid('getPager');

				$(p).pagination({
					pageSize: 10,//每页显示的记录条数，默认为10
					pageList: [10,15],//可以设置每页记录条数的列表
				 	beforePageText: '第',//页数文本框前显示的汉字
				   	afterPageText: '页    共 {pages} 页',
				   	displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
				});
			}
			function channelConfirm(){
				//拼装地区名称展示
				var channelNames = '';
				//拼装地区Id
				var channelIds = '';

				var row = $("#channelQuery").datagrid('getSelected');

				if(row){
					$('#pubChannelId').val(row.channelId);
					$('#pubChannelName').val(row.name);
					$("#channelDiv").window('close');

				}else{
					//	$.messager.alert('提示信息','请选择一个渠道!','info');
					$('#pubChannelId').val(null);
					$('#pubChannelName').val(null);
					$("#channelDiv").window('close');
				}

			}
			function channelCancel(){
				$("#channelDiv").window('close');
			}
		</script>
	</body>
</html>
